package compare;

public class Demo {
    public static void main(String[] args) {
    //基本数据类型比较
        //整型类型比较
        int a = 10;
        int b = 20;
        //返回 true 或者 false
        System.out.println(a > b);      //false
        System.out.println(a < b);      //true
        System.out.println(a == b);     //false

        //字符型比较
        char c = 'A';
        char d = 'B';
        //返回 true 或者 false
        System.out.println(c > d);      //false
        System.out.println(c < d);      //true
        System.out.println(c == d);     //false

        //布尔类型比较
        boolean e = true;
        boolean f = false;
        //只能用 == 或者 != 来比较
        System.out.println(e == f);     //false
        System.out.println(e != f);     //true

    //引用数据类型比较
        String s1 = new String("hello");
        String s2 = new String("hello");
        String s3 = new String("world");
        String s4 = s1;
        System.out.println(s1 == s2);       //false
        System.out.println(s1 == s3);       //false
        System.out.println(s1 == s4);       //true
        System.out.println(s1.equals(s2));      //true
        System.out.println(s1.equals(s3));      //false
        System.out.println(s1.equals(s4));      //true
    }
}
